package com.google.code.timetrail.gui;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.google.code.timetrail.backend.*;

import java.awt.CardLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class TakingMoveFrame extends JPanel {

	private TakingMoveFrameBackend takingMoveFrameBackend;
	
	/**
	 * Create the panel.
	 */
	private Control myGameControl;
	private JPanel myCD;
	private JLabel lblFood;
	private JLabel lblDistance;
	private JLabel lblRations;
	private JLabel lblPace;
	private JLabel lblTurn;
	private String myPrevious;
	
	public TakingMoveFrame(Control gameControl, JPanel cd, String previous) {
		this.myGameControl = gameControl;
		this.myCD = cd;
		this.myPrevious = previous;
		setLayout(null);
		
		takingMoveFrameBackend = new TakingMoveFrameBackend(myGameControl);
		
		lblTurn = new JLabel(takingMoveFrameBackend.getTurnLabelText());
		lblTurn.setBounds(370, 11, 100, 14);
		add(lblTurn);
		
		lblFood = new JLabel(takingMoveFrameBackend.getFoodLabelText());
		lblFood.setBounds(370, 36, 100, 14);
		add(lblFood);
		
		lblDistance = new JLabel(takingMoveFrameBackend.getDistanceLabelText());
		lblDistance.setBounds(370, 61, 100, 14);
		add(lblDistance);
		
		lblRations = new JLabel(takingMoveFrameBackend.getRationsLabelText());
		lblRations.setBounds(370, 86, 200, 14);
		add(lblRations);
		
		lblPace = new JLabel(takingMoveFrameBackend.getPaceLabelText());
		lblPace.setBounds(370, 111, 200, 14);
		add(lblPace);
		
		JButton btnNewButton = new JButton(takingMoveFrameBackend.getPaceRationsButtonText());
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				myCD.add(new RationsPaceFrame(myGameControl, myCD, "TakeMove"), "name_1317840867491837002");
                CardLayout cd = (CardLayout) myCD.getLayout();
                cd.next(myCD);
			}
		});
		btnNewButton.setBounds(28, 255, 161, 23);
		add(btnNewButton);
		
		JButton btnContinue = new JButton(takingMoveFrameBackend.getContinueButtonText());
		btnContinue.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				takingMoveFrameBackend.pressContinue();
				lblFood.setText(takingMoveFrameBackend.getFoodLabelText());
				lblDistance.setText(takingMoveFrameBackend.getDistanceLabelText());
				lblTurn.setText(takingMoveFrameBackend.getTurnLabelText());
			}
		});
		btnContinue.setBounds(238, 255, 161, 23);
		add(btnContinue);
		
		

	}
}
